// *************************************************************************************************
//
// MK3D Engine
// --------------------------------------
// Copyright (C) 2007-2011 Zeb (mailto: zebbey@gmail.com)
//
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
// *************************************************************************************************

#include "mk_header.h"
#include "mk_water.h"

namespace MK3DE
{
	CWater::CWater()
	{
		_width = 0;
		_height = 0;
		_gridSize = 0;
	}

	CWater::~CWater()
	{

	}

	BOOL CWater::CreateMesh(DWORD dwWidth, DWORD dwHeight, float fGridSize)
	{
		__ClearWaterData();

		_waterData.vecPosition.reserve((dwWidth + 1) * (dwHeight + 1));

		for (DWORD j = 0; j < dwHeight + 1; ++j)
		{
			for (DWORD i = 0; i < dwWidth + 1; ++i)
			{
				float x = i * fGridSize;
				float y = 0.0f;
				float z = j * fGridSize;
				_waterData.vecPosition.push_back(CMesh::Position(x, y, z));
			}
		}

		_width = dwWidth;
		_height = dwHeight;
		_gridSize = fGridSize;

		return TRUE;
	}

	void CWater::__ClearWaterData()
	{
		_waterData.vecPosition.clear();
		_width = 0;
		_height = 0;
		_gridSize = 0;
	}
}